package org.pralu.siruri;

import java.util.Scanner;

public class BazaK {

	/*
	 * 11/55 Se citeste un nr nat n. cate cifre are reprezentarea lui in baza 2?
	 * 12/55 se citesc n,k nr nat, unde k apartine [2,9]. Cate cifre are nr n
	 * exprimat in baza k?
	 */
	public static void main(String[] args) {
		int n;
		Scanner in = new Scanner(System.in);
		System.out.println("introduceti un numar natural");
		n = in.nextInt();

		int c; // nr cifrelor reprezentarii nr in baza 2
		c = 0;
		while (n > 0) {
			n = n / 2;
			c = c + 1;
		}
		System.out.println("numarul in baza 2 are " + c + " cifra/e");

		// ex 12
		int k;
		int c2;// numarul cifrelor pt pb 12
		c2 = 0;
		int nr;
		System.out.println("introduceti alt numar natural");
		nr = in.nextInt();
		System.out.println("introduceti noua baza");
		k = in.nextInt();
		if ((k >= 2) & (k <= 9)) {
			while (nr > 0) {
				nr = nr / k;
				c2 = c2 + 1;
			}
			System.out.println("numarul in baza " + k + " are " + c2
					+ " cifra/e");
		} else {
			System.out.println("baza trebuie sa fie cuprinsa intre 2 si 9");
		}
	}
}
